package com.wd.jetpack.base

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment

/**
 * NA<BR>
 *
 * @author W4255
 * @version [V0.0.1, 2021/6/26]
 * @Description: NA
 */
abstract class BaseFragment<VB : ViewDataBinding> : Fragment() {
    //声明binding
    protected val mBinding: VB by lazy {
        DataBindingUtil.inflate<VB>(layoutInflater, getLayoutId(), null, false)
    }

    abstract fun getLayoutId(): Int
    abstract fun initView(view: View)
    abstract fun initData()

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
//        val root = inflater.inflate(R.layout.fragment_tab_main, container, false)
        //绑定生命周期
        mBinding.lifecycleOwner = this
        initView(mBinding.root)
        initData()
        return mBinding.root
    }
}